import request from '@/utils/request'

export const roleList = () => {
    return request({
      url: '/admin/role/roleList',
      method: 'get'
    })
  }
  
  export const list = (query) => {
    return request({
      url: '/admin/role/page',
      method: 'get',
      params: query
    })
  }
  
  export const deptRoleList = () => {
    return request({
      url: '/admin/role/list',
      method: 'get'
    })
  }
  
  export const getObj = (id) => {
    return request({
      url: '/admin/role/' + id,
      method: 'get'
    })
  }
  
  export const addObj = (obj) => {
    return request({
      url: '/admin/role',
      method: 'post',
      data: obj
    })
  }
  
  export const updateObj = (obj) => {
    return request({
      url: '/admin/role',
      method: 'put',
      data: obj
    })
  }
  
  export const delObj = (id) => {
    return request({
      url: '/admin/role/' + id,
      method: 'delete'
    })
  }
  
  export const  permissionUpd = (roleId, menuIds) => {
    return request({
      url: '/admin/role/menu',
      method: 'put',
      data: {
        roleId: roleId,
        menuIds: menuIds
      }
    })
  }
  
  export const fetchRoleTree = (roleId) => {
    return request({
      url: '/admin/menu/tree/' + roleId,
      method: 'get'
    })
  }
  
  